<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form id="listFuncionarios">
            <fieldset>
                <legend>Funcionários cadastrados</legend>
                <c:choose>
                    <c:when test="#{!empty funcionarioBean.funcionarios}">
                        <h:dataTable value="#{funcionarioBean.funcionarios}" var="funcionario"
                                     rules="rows" border="1" binding="#{funcionarioBean.table}">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Id"/>
                                </f:facet>
                                <h:outputText value="#{funcionario.id}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Nome"/>
                                </f:facet>
                                <h:outputText value="#{funcionario.nome}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="CPF"/>
                                </f:facet>
                                <h:outputText value="#{funcionario.cpf}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Nivel Acesso"/>
                                </f:facet>
                                <h:outputText value="#{funcionario.nivelAcesso}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Remover" />
                                </f:facet>
                                <h:commandButton action="#{funcionarioBean.remove}" value="Remover"
                                                 onclick="if(!confirm('Deseja remover o funcionário #{funcionario.nome}?')) return false"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Editar" />
                                </f:facet>
                                <h:commandButton action="#{funcionarioBean.goToEditPage}" value="Editar" />
                            </h:column>
                        </h:dataTable>
                    </c:when>
                    <c:otherwise>
                        <h:outputText value="Não há nenhum funcionario cadastrado."/><br />
                    </c:otherwise>
                </c:choose>
                <h:commandButton value="Voltar" action="createFuncionario" />
                <h:commandButton value="Principal" action="principal" />
            </fieldset>
        </h:form>
    </h:body>
</html>

